15/11/2017
How to fetch all posts using tumblr API
CLOSED:
:PUBDATE:
:ID: 9d3fabcf-279c-4998-b0d0-766be61c1913
You can put this code in your html or php.
<script type="text/javascript" src="http://YourTumblrName.tumblr.com/js?start='post'&num='posts-total'"></script>
It fetches the content of your tumblr into a page, but it not very flexible. I'm still trying to get the dates and tags fetched. And the image quality is not as good as in Tumblr…
How to parse tumblr JSON feed zero
visto che nel JSON file sono presenti solo 20 post preferisco la soluzione precedente, anche se meno bella
<script type="text/javascript" src="http://ordine-complicato.tumblr.com/api/read/json"></script> <script type="text/javascript> var tumblr_api_read = { "tumblelog": { "title": "First Title", "description": "", "name": "clintonbeattie", "timezone": "US/Eastern", "cname": false, "feeds": [] }, "posts": [{ "id": null, "url": "", "url-with-slug": "", "type": "regular", "date-gmt": " GMT", "date": "Wed, 31 Dec 1969 19:00:00", "bookmarklet": null, "mobile": null, "feed-item": "", "from-feed-id": 0, "unix-timestamp": 1333622193, "format": "html", "reblog-key": "TmN3ujDJ", "slug": "", "regular-title": "", "regular-body": "" }] }; </script>
Use tumblrapiread. zero
<script src="http://ordine-complicato.tumblr.com/bio/json"></script> <script> alert(tumblr_api_read.tumblelog.title); // Shows "First Title" alert(tumblr_api_read.posts.length); // numero di post for (var i=0;i<tumblr_api_read.posts.length;i++) { var thisPost = tumblr_api_read.posts[i]; // alert("This post was created at " + thisPost.date); photourl = "<img style='display: block; border:0px;' src='" + tumblr_api_read["posts"][i]["photo-url-400"] + "' />"; document.write(photourl); } </script> <script type="text/javascript" src="http://ordine-complicato.tumblr.com/api/read/json"></script> <script type="text/javascript"> var posts = tumblr_api_read['posts-total'] // total posts var totalposts = "<b>Total posts:</b> "; document.write(totalposts) document.write(posts) </script> <script type="text/javascript"> nmax = 50; n = tumblr_api_read["posts-total"]; if (n > nmax) n = nmax; for (i = 0; i < n; i++) { photourl = "<img style='display: block; border:0px;' src='" + tumblr_api_read["posts"][i]["photo-url-400"] + "' />"; document.write(photourl); } </script> <script type="text/javascript"> // The variable "tumblr_api_read" is now set. document.write( '<a href="' + tumblr_api_read[1][0]['url'] + '">Most recent Tumblr post</a>' ); </script>
(boh! non ricordo da dove ho tirato fuori questi esempi, penso da https://pastebin.com)